package homework;

public class homework7HuiwenSushu {
	public static void main(String[] args){
		int count = 0;
		for(int i = 0; i < 1000;i++){
			if(Prime(i) && Palindrome(i)){
				System.out.printf(i + " ");
				count++;
				if(count == 10){
					System.out.println(" ");
					count = 0;
				}
			}
		}
	}
	
	public static boolean Prime(int num) {
		boolean result = true;
		for(int i = 1;i < num;i++){
			if(num % i == 0 && i != 1){
				result = false;
			}
		}
		return result;
	}
	
	public static boolean Palindrome(int num){
		boolean result = false;
		if(num >= 1 && num < 10){
			result = true;
		}else if(num >= 10 && num < 100){
			if(num / 10 == num % 10){
				result = true;
			}
		}else if(num >=100 && num <1000){
			if(num / 100 == num % 10){
				result = true;
			}
		}
		return result;
	}
}
